package com.hl.sfzy.controller.wxwappController;

import com.hl.sfzy.entity.wxwapp.WXWConsultwait;
import com.hl.sfzy.entity.wxwapp.WXWConsultwaitName;
import com.hl.sfzy.service.wxwappService.WXWConsultWaitService;
import com.hl.sfzy.service.wxwappService.WXWHeartMarkService;
import com.hl.sfzy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @className: WXWConsultWaitController
 * @author: WXW
 * @date: 2024/9/11 23:00
 * @Version: 1.0
 * @description:
 */
@RestController
@RequestMapping("/consultWait")
public class WXWConsultWaitController {
    @Autowired
    private WXWConsultWaitService wXWConsultWaitService;

    //    查询所有预约信息
    @GetMapping("/selectAllWXWConsultwaitName")
    public R selectAllReservation(Integer page, Integer size) {
        return wXWConsultWaitService.findAllReservation(page, size);
    }

    //    查询所有的咨询是的id和name
    @GetMapping("/selectAllTeacherNameId")
    public R selectAllTeacherIdName() {
        return wXWConsultWaitService.findAllTeacherIdAndName();
    }

    //    查询所有User的id和name
    @GetMapping("/selectAllUserNameId")
    public R selectAllUserIdName() {
        return wXWConsultWaitService.findAllUserIdAndName();
    }

    //  新增
    @PostMapping("/insertWXWConsultwait")
    public R insertWXWConsultwait(@RequestBody WXWConsultwait wxwConsultwait) {
        System.out.println("wxwConsultwait = " + wxwConsultwait);
        return wXWConsultWaitService.addReservation(wxwConsultwait);
    }

    //通过id查询带name的Reservation对象
    @GetMapping("/selectWXWConsultwaitNameById")
    public R selectReservationWithName(Integer id) {
        return wXWConsultWaitService.findReservationById(id);
    }

    //修改
    @PutMapping("/updateWXWConsultwait")
    public R updateWXWConsultwait(@RequestBody WXWConsultwaitName wxwConsultwaitName) {
        return wXWConsultWaitService.updateReservation(wxwConsultwaitName);
    }

    //删除
    @DeleteMapping("/deleteWXWConsultwait")
    public R deleteReservation(Integer id) {
        return wXWConsultWaitService.deleteReservation(id);
    }

    //    根据咨询师的姓名模糊查询预约信息
    @GetMapping("/selectWXWConsultwaitNameByTeacher")
    public R selectReservationWithName(String name, Integer page, Integer size) {
        return wXWConsultWaitService.findReservationByTeacherName(name, page, size);
    }
}
